package b1.scenes.fight
{
	import b1.conifg.*;
	import b1.controls.basic.*;
	import b1.net.*;
	
	import com.greensock.*;

	public class FrogTongue extends FightObject
	{
		public var leftFlag:Boolean;
		private var index:int;
		private var tongueImg:BasicMc;
		
		public function FrogTongue(index:int, leftFlag:Boolean)
		{
			super(leftFlag);
			this.index = index;
			this.leftFlag = leftFlag;
			var obstacleConfig:ObstacleConfig = Config.obstacleConfigs[index];
			hitPoints = obstacleConfig.hitPoints;
		}
		
		public function strechOut():void
		{
			if (tongueImg != null && tongueImg.parent != null)
			{
				tongueImg.parent.removeChild(tongueImg);
				tongueImg = null;
			}
			var TongueImg:Class = ResourceHelper.getInstance().getClassByName("Obstacle" + index);
			tongueImg = new BasicMc(TongueImg, 30, false);
			if (!leftFlag)
				tongueImg.scaleX = -1;
			addChild(tongueImg);
		}
		
		public function drawBack():void
		{
			if (tongueImg != null && tongueImg.parent != null)
			{
				tongueImg.parent.removeChild(tongueImg);
				tongueImg = null;
			}
			var TongueImg:Class = ResourceHelper.getInstance().getClassByName("Obstacle" + index);
			tongueImg = new BasicMc(TongueImg, -30, false);
			if (!leftFlag)
				tongueImg.scaleX = -1;
			addChild(tongueImg);
		}
		
		public override function destroy():void
		{
			super.destroy();
			if (this.parent != null)
				this.parent.removeChild(this);
		}
		
	}
}